﻿/*  
	------------------------------------------------------------------------
	 NQ Core Library
	
	 Homepage: http://www.awzhome.de/
	------------------------------------------------------------------------
	
	This Source Code Form is subject to the terms of the Mozilla Public
	License, v. 2.0. If a copy of the MPL was not distributed with this
	file, You can obtain one at http://mozilla.org/MPL/2.0/.
   
	The Original Code is code of NQ Core Library.

	The Initial Developer of the Original Code is Andreas Weizel.
	Portions created by the Initial Developer are
	Copyright (C) 2012 Andreas Weizel. All Rights Reserved.
	
	Contributor(s): (none)
	
	------------------------------------------------------------------------
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AWZhome.NQ.Core.Fluent
{
	/// <summary>
	/// Wrapper class to support easier setting of the log level.
	/// </summary>
	public class LogLevelWrapper
	{
		/// <summary>
		/// Activates a log level.
		/// </summary>
		/// <param name="wrapper">
		/// A <see cref="AWZhome.NQ.Core.Fluent.LogLevelWrapper">LogLevelWrapper</see> instance containing active log levels.
		/// </param>
		/// <param name="type2">Log level to activate.</param>
		/// <returns><see cref="AWZhome.NQ.Core.Fluent.LogLevelWrapper">LogLevelWrapper</see> with the new level set.</returns>
		public static LogLevelWrapper operator +(LogLevelWrapper wrapper, NQLogType type2)
		{
			wrapper.LogType = wrapper.LogType | type2;
			return wrapper;
		}

		/// <summary>
		/// Disables a log level.
		/// </summary>
		/// <param name="wrapper">
		/// A <see cref="AWZhome.NQ.Core.Fluent.LogLevelWrapper">LogLevelWrapper</see> instance containing active log levels.
		/// </param>
		/// <param name="type2">Log level to disable.</param>
		/// <returns><see cref="AWZhome.NQ.Core.Fluent.LogLevelWrapper">LogLevelWrapper</see> with the new level set.</returns>
		public static LogLevelWrapper operator -(LogLevelWrapper wrapper, NQLogType type2)
		{
			wrapper.LogType = wrapper.LogType & ~type2;
			return wrapper;
		}

		/// <summary>
		/// Operator to convert a <see cref="AWZhome.NQ.Core.Fluent.LogLevelWrapper">LogLevelWrapper</see>
		/// to a <see cref="AWZhome.NQ.Core.NQLogType">NQLogType</see> value.
		/// </summary>
		/// <param name="wrapper">Wrapper object</param>
		/// <returns>Converted <see cref="AWZhome.NQ.Core.NQLogType">NQLogType</see> value.</returns>
		public static implicit operator NQLogType(LogLevelWrapper wrapper)
		{
			return wrapper.LogType;
		}

		/// <summary>
		/// Operator to convert a <see cref="AWZhome.NQ.Core.NQLogType">NQLogType</see> value
		/// to a <see cref="AWZhome.NQ.Core.Fluent.LogLevelWrapper">LogLevelWrapper</see> instance.
		/// </summary>
		/// <param name="wrapper">Converted <see cref="AWZhome.NQ.Core.NQLogType">NQLogType</see> value.</param>
		/// <returns>New wrapper object.</returns>
		public static implicit operator LogLevelWrapper(NQLogType logType)
		{
			return new LogLevelWrapper()
			{
				LogType = logType
			};
		}

		/// <summary>
		/// Returns the <see cref="AWZhome.NQ.Core.NQLogType">NQLogType</see> value from the wrapper object.
		/// </summary>
		internal NQLogType LogType
		{
			private get;
			set;
		}
	}
}
